<template>
  <div class="risk">
    <div
      class="add"
      @click="add()"
    >创建证书</div>
    <eagle-page-list
      ref="eaglePageList"
      @bindData="bindData"
      :queryParams="queryParams"
      :controller="controller"
      placeholder="请输入证书编号,证书名称搜索"
      :conditions="conditions"
      :pageSize="20"
    >
      <div slot="list">
        <eagle-cell
          style="margin-top: 10px"
          class="br-8"
          v-for="(item, index) in list"
          :key="index"
        >
          <div>
            <div @click="views(item)">
              <eagle-row gutter="15">
                <eagle-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />证书名称：{{ item.CertName }}
                </eagle-col>
              </eagle-row>
              <eagle-row gutter="20">
                <eagle-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_type.png"
                  />证书编号：{{ item.CertCode }}
                </eagle-col>
              </eagle-row>
              <eagle-row gutter="20">
                <eagle-col>
                  <img
                    class="icon"
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                  />有限期：{{ item.NextReviewDate|formatDate }}
                </eagle-col>
              </eagle-row>
              <van-divider />
              <eagle-button
                class="ml-10 mb-5"
                style="float: right;height:30px;"
                size="small"
                type="default"
                @@click.stop="edit(item)"
              >编辑
              </eagle-button>
              <eagle-button
                class="ml-10 mb-5"
                style="float: right;height:30px;"
                size="small"
                type="default"
                @@click.stop="del(item)"
              >删除
              </eagle-button>
            </div>

          </div>

        </eagle-cell>
      </div>
    </eagle-page-list>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  props: {},
  data() {
    return {
      value: "",
      list: [],
      queryParams: {
        dataType: "UserCertList",
        keywords: "",
      },
      controller: "/ConstructSafeUserCert",
      conditions: {},
      loading: false,
      finished: false,
    };
  },
  created() {},
  computed: {
    ...mapGetters(["roles"]),
  },
  methods: {
    bindData(data) {
      this.list = [];
      if (data) {
        this.list = data;
      }
    },
    add() {
      this.$router.push({
        path: "ConstructSafeCertDetail",
        query: { id: 0 },
      });
    },
    edit(item) {
      this.$router.push({
        path: "ConstructSafeCertDetail",
        query: { id: item.ID },
      });
    },
    views(item) {
      this.$router.push({
        path: "ConstructSafeCertView",
        query: { id: item.ID },
      });
    },
    del(item) {
      var that = this;
      that.$dialog
        .confirm({
          title: "询问",
          message: "您确定要删除该证书吗？",
        })
        .then(() => {
            that.$axios
            .get("/ConstructSafeUserCert/Delete",{params:{ id: item.ID }})
            .then((res) => {
              that.$toast.success("删除成功！");
              setTimeout(() => {
                that.$refs.eaglePageList.search({});
              }, 300);
            });
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
</script>

<style lang="less" scoped>
.risk {
  background-color: #e8f1f8;
  .info_search {
    padding: 10px;
    border-radius: 5px !important;
    .van-field__control {
      background-color: #ffffff !important;
    }
  }
}
.all_dep {
  background-color: #ffffff;
}
.van-cell {
  padding: 0 0;
}
.warn_item {
  padding: 10px 10px;
  background-color: #ffffff;
  /*margin-bottom: 10px;*/

  border-radius: 5px;
  position: relative;
}
.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: -10px;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.warn_item {
  .van-radio {
    position: absolute;
    right: 10px;
    top: 41px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  line-height: 27px;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>
